package com.sajus.billing.client.util;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class EJBLocalServiceLocator implements EJBServiceLocator {
	static private EJBServiceLocator instance = new EJBLocalServiceLocator();

	private EJBLocalServiceLocator() {
		super();	
	}
	
	public static EJBServiceLocator getInstance() {
		return instance;
	}
	
	public <T> T locate(EJBs name) throws NamingException {
		Context ctx = new InitialContext();
        Object o = ctx.lookup("ejb:SajusBillingEAR/SajusBillingEJB/" + name.toString() + "!" + name.getLocalInterface() );
        ctx.close();
        return (T)o;
	}
}
